FROM {{ namespace }}/{{ image_prefix }}octavia-base:{{ tag }}
{% block labels %}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% endblock %}

{% block octavia_api_header %}{% endblock %}

{% import "macros.j2" as macros with context %}

{% if install_type == 'binary' %}
    {% if base_package_type == 'rpm' %}
        {% set octavia_api_packages = [
            'openstack-octavia-api',
            'python3-ovn-octavia-provider'
        ] %}
    {% elif base_package_type == 'deb' %}
        {% set octavia_api_packages = [
            'octavia-api'
        ] %}

        {% if base_distro == 'debian' %}
            {% set octavia_api_packages = octavia_api_packages + [
                'python3-networking-ovn'
            ] %}
        {% elif base_distro == 'ubuntu' %}
            {% set octavia_api_packages = octavia_api_packages + [
                'python3-ovn-octavia-provider'
            ] %}
        {% endif %}

    {% endif %}

{% elif install_type == 'source' %}
    {% set octavia_api_packages = [
    ] %}

    {% set octavia_api_plugins_pip_packages = [
        '/plugins/*'
    ] %}

ADD plugins-archive /
RUN if [ "$(ls /plugins)" ]; then \
        {{ macros.install_pip(octavia_api_plugins_pip_packages) }} ; \
    fi
{% endif %}

{{ macros.install_packages(octavia_api_packages | customizable("packages")) }}

COPY extend_start.sh /usr/local/bin/kolla_octavia_extend_start
RUN chmod 755 /usr/local/bin/kolla_octavia_extend_start

{% block octavia_api_footer %}{% endblock %}
{% block footer %}{% endblock %}

USER octavia
